package com.cdtye.itps.cms.controller.mock;


import com.cdtye.common.webcore.web.AjaxJson;
import com.cdtye.itps.cms.dao.result.AnalyseProgressResVo;
import com.cdtye.itps.cms.dao.result.OriginalDataCheckVo;
import com.cdtye.itps.cms.dao.result.TestPlanCompleteRateResVo;
import com.cdtye.itps.cms.mapper.origindata.JcjcDetectC1JobMapper;
import com.cdtye.itps.cms.mapper.origindata.JcjcDetectC2JobMapper;
import com.cdtye.itps.cms.mapper.origindata.JcjcDetectC4JobMapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;

/**
 * 线路站 前端控制器
 * @author Jchen
 * @date 2021-07-08
 */
@Api(tags="假数据接口")
@RestController
@RequestMapping("/mock")
public class MockController {
    @Autowired
    private JcjcDetectC1JobMapper jcjcDetectC1JobAMapper;
    @Autowired
    private JcjcDetectC2JobMapper jcjcDetectC2JobAMapper;
    @Autowired
    private JcjcDetectC4JobMapper jcjcDetectC4JobAMapper;

    @GetMapping(value = "/analyseProgress")
    @ApiOperation(value = "6C分析进度")
    public AjaxJson<AnalyseProgressResVo> analyseProgress(OriginalDataCheckVo vo){
        //  todo
        AnalyseProgressResVo v=new AnalyseProgressResVo();
        v.setComplete1C(10);
        v.setSum1C(100);
        v.setCompleteRate1C("10.00");
        if(v.getSum1C()!=0 && v.getComplete1C()!=0){
            v.setCompleteRate1C(new BigDecimal(v.getComplete1C()*100).divide(new BigDecimal(v.getSum1C()),2,BigDecimal.ROUND_HALF_UP).toString());
        }

        v.setComplete2C(50);
        v.setSum2C(200);
        v.setCompleteRate2C("25.00");
        if(v.getSum2C()!=0 && v.getComplete2C()!=0){
            v.setCompleteRate2C(new BigDecimal(v.getComplete2C()*100).divide(new BigDecimal(v.getSum2C()),2,BigDecimal.ROUND_HALF_UP).toString());
        }
        v.setCompleteRate2C("96.54");

        v.setComplete3C(50);
        v.setSum3C(250);
        v.setCompleteRate3C("20.00");
        if(v.getSum3C()!=0 && v.getComplete3C()!=0){
            v.setCompleteRate3C(new BigDecimal(v.getComplete3C()*100).divide(new BigDecimal(v.getSum3C()),2,BigDecimal.ROUND_HALF_UP).toString());
        }
        v.setCompleteRate3C("87.36");
        v.setComplete4C(70);
        v.setSum4C(200);
        v.setCompleteRate4C("35.00");
        if(v.getSum4C()!=0 && v.getComplete4C()!=0){
            v.setCompleteRate4C(new BigDecimal(v.getComplete4C()*100).divide(new BigDecimal(v.getSum4C()),2,BigDecimal.ROUND_HALF_UP).toString());
        }
        v.setCompleteRate4C("83.21");
        v.setComplete5C(50);
        v.setSum5C(100);
        v.setCompleteRate5C("50.00");
        if(v.getSum5C()!=0 && v.getComplete5C()!=0){
            v.setCompleteRate5C(new BigDecimal(v.getComplete5C()*100).divide(new BigDecimal(v.getSum5C()),2,BigDecimal.ROUND_HALF_UP).toString());
        }

        v.setComplete6C(55);
        v.setSum6C(100);
        v.setCompleteRate6C("55.00");
        if(v.getSum6C()!=0 && v.getComplete6C()!=0){
            v.setCompleteRate5C(new BigDecimal(v.getComplete6C()*100).divide(new BigDecimal(v.getSum6C()),2,BigDecimal.ROUND_HALF_UP).toString());
        }
        return AjaxJson.success(v);
    }

    @GetMapping(value = "/originalDataCheck")
    @ApiOperation(value = "原始检测数据")
    public AjaxJson<TestPlanCompleteRateResVo> originalDataCheck(OriginalDataCheckVo vo){
        TestPlanCompleteRateResVo response=new TestPlanCompleteRateResVo();
        response.setCompleteRate1C("0.00");
        response.setCompleteRate1C("0.00");
        response.setCompleteRate1C("0.00");
        response.setSum1C("0.6");
        response.setSum2C("1.3");
        response.setSum4C("0.9");
        response.setComplete1C(jcjcDetectC1JobAMapper.selectCount(null).toString());
        response.setComplete2C(jcjcDetectC2JobAMapper.selectCount(null).toString());
        response.setComplete4C(jcjcDetectC4JobAMapper.selectCount(null).toString());
        return AjaxJson.success(response);
    }
}
